<template>
<div>
  <div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">会员姓名</div>
      <div class="zan-field__input zan-cell__bd">{{user.name}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">会员性别</div>
      <div class="zan-field__input zan-cell__bd">{{user.sex1}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">出生年月</div>
      <div class="zan-field__input zan-cell__bd">{{user.birthday1}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">手机号码</div>
      <div class="zan-field__input zan-cell__bd">{{user.mobile}}</div>
      <div class="zan-cell__ft" style="border-left:1px solid black;">
        <span style="padding-left:8px;padding-right:8px;">修改号码</span>
      </div>
    </div>
    <div style="height:10px;background: #F0F0F0"></div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">会员卡号</div>
      <div class="zan-field__input zan-cell__bd">{{user.card_no}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">账户余额</div>
      <div class="zan-field__input zan-cell__bd">￥{{user.balance/100}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">账户积分</div>
      <div class="zan-field__input zan-cell__bd">{{user.points}}</div>
    </div>
    <div class="zan-cell zan-field">
      <div class="zan-cell__hd zan-field__title">会员级别</div>
      <div class="zan-field__input zan-cell__bd">{{user.card_tpl_name}}</div>
    </div>
    <div class="zan-cell zan-field" style="border-bottom: 1rpx solid #F0F0F0;">
      <div class="zan-cell__hd zan-field__title">办卡时间</div>
      <div class="zan-field__input zan-cell__bd">{{user.created_at1}}</div>
    </div>
  </div>
</div>
</template>

<script>
import {
  formatTime
} from '@/utils/index'
import {
  mapGetters
} from 'vuex'

export default {
  data() {
    return {
    }
  },
  computed: {
    ...mapGetters([
      'user',
    ])
  },
  beforeMount() {
    console.log('beforeMount')
    if (!this.user || !this.user.id) {
      // 用户未授权
      let url = 'get_user_info?callback_url=member_info'
      wx.redirectTo({
        url: url
      })
      return
    }

    if (this.user) {
      // 用户已授权
      this.user.birthday1 = this.user.birthyear + '-' + this.user.birthday
      this.user.created_at1 = formatTime(this.user.created_at)
      if (this.user.sex == 'male') {
        this.user.sex1 = '男'
      } else {
        this.user.sex1 = '女'
      }
    }
  },
  methods:{
    formatSex(val){
      console.log('sex')
      console.log(val)
      if(val=='male'){
        return '男'
      }else{
        return '女'
      }
    },
    formatCreatedAt:function(val){
      console.log(val)
      return formatTime(val)
    },
  }
}
</script>

<style>
</style>
